import 'package:flutter/material.dart';
import 'package:flutterdemo/model/common_model.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutterdemo/navigator/tab_navigator.dart';

void main() => runApp(const MyApp());


class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter行程助手',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: TabNavigator(),
    );
  }
}

// class MyApp extends StatefulWidget {
//   const MyApp({Key? key}) : super(key: key);
//
//   @override
//   State<StatefulWidget> createState() => _MyAppState();
// }
//
// class _MyAppState extends State<MyApp> {
//   String countString = '';
//   String localCount = '';
//
//   @override
//   Widget build(BuildContext context) {
//     return MaterialApp(

//       home: Scaffold(
//         appBar: AppBar(
//           title: Text('Http'),
//         ),
//          body: Column(children: <Widget>[
//            RaisedButton(
//                onPressed: _incrementCounter,
//            child: Text('Increment Count'),
//            ),
//            RaisedButton(
//                onPressed: _getCounter,
//              child: Text('Get Count'),),
//            Text(
//              countString,
//              style: TextStyle(fontSize: 20),
//            ),
//            Text(
//              localCount,
//              style: TextStyle(fontSize: 20),
//            ),
//          ],)
//       )
//     );
//   }
//   _incrementCounter() async {
//      SharedPreferences preferences = await SharedPreferences.getInstance();
//      setState(() {
//        countString = countString + " 1";
//      });
//      int counter = (preferences.getInt('counter') ?? 0) + 1;
//      await preferences.setInt('counter', counter);
//   }
//
//   _getCounter() async {
//     SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
//     setState(() {
//       localCount = sharedPreferences.getInt('counter').toString();
//     });
//   }
// }

// FutureBuilder<CommonModel> (
// //没有指定future就不会有效果
// future: fetchPost(),
// builder:
// (BuildContext context, AsyncSnapshot<CommonModel> snapshot) {
// switch (snapshot.connectionState) {
// case ConnectionState.none:
// return new Text('Input a URL to start');
// case ConnectionState.waiting:
// return new Center(child: CircularProgressIndicator(),);
// case ConnectionState.active:
// return new Text('');
// case ConnectionState.done:
// if (snapshot.hasError) {
// return new Text(
// '${snapshot.error}',
// style: TextStyle(color: Colors.red),
// );
// } else {
// return new Column(children: <Widget>[
// Text('icon:${snapshot.data?.icon}'),
// Text('icon:${snapshot.data?.statusBarColor}'),
// Text('icon:${snapshot.data?.title}'),
// Text('icon:${snapshot.data?.url}')
// ]);
// }
// }
// }),



